How to hack drag-aware text editors to allow you to delete text dropped over Trash It!
by Ammon Skidmore <mailto:ammon@cs.byu.edu>, November 3, 1995
The Background:
---------------
Apple's drag manager sample code does an overkill check to see if the drag was dropped on the Finder's trash can. One of its criteria is that the drag must leave the sender application:
GetDragAttributes(theDrag, &attributes);
if (!(attributes & dragInsideSenderApplication)) {
GetDropLocation(theDrag, &dropLocation);
...
}
While this is ok for normal use, it breaks when drags enter a floating window. So to fix this situation, I could either
a) patch the drag manager like crazy (no!)
b) figure out the undocumented format of the DragReference so that we can manually turn off the dragInsideSenderApplication flag in our code (no!)
c) patch each offending application (yes!)
The Hack:
---------
We will operate, for example, on SimpleText 1.2. Here is the code piece of interest:
Note the number 2 moved into D0 after GetDragAttributes is called. This is the constant dragInsideSenderApplication. All that the hack consists of is changing this number to zero, so that the bit-wise AND always returns zero.
Open a copy of your favorite drag-aware text editor in ResEdit, Resorcerer, or some sort of utility that can find hex strings in the resource fork of files. Tip: Resorcerer is _very_ nice for this.
If this hack was only for SimpleText, then we would just search for '7019ABED7002' and change it to '7019ABED7000'. But, the program Stickies shrinks the stack after it calls _GetDragAttributes, so the following is necessary:
a) Open a CODE resource (for SimpleText it is id 6, 'Text').
b) Search for: '7019ABED'.
c) See if there are any nearby occurrences of '7002'.
d) If not, goto step b until an occurrence is found, or the end of the resource is reached in which case you should open the next CODE resource and try again.
e) Change '7002' to '7000'.
That's it!
This hack has so far been tested successfully on:
SimpleText - modify CODE id 6, 'Text'
Stickies - modify CODE id 7
Tex-Edit Plus - modify CODE id 1, 'Main'
(can you add any more?)
Also, this hack is not necessary for the following programs: